class Solution {
public:
    int countTestedDevices(vector<int>& nums)
    {
        int ans = 0;
        int n = nums.size();
        for (int i = 0; i < n; i++)
        {
            if (nums[i] > 0)
            {
                ans++;
                for (int j = i + 1; j < n; j++)
                    if (nums[j] != 0) nums[j]--;
            }
        }
        return ans;
    }
};